#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int a, b, p;
bool fprime[N];
int fa[N];
int find(int x){
    if (fa[x] == x)
        return x;
    fa[x] = find(fa[x]);
    return fa[x];
}

int main()
{
    scanf("%d%d%d", &a, &b, &p);
    memset(fprime,0, sizeof(fprime));
    for (int i = 1; i <= b; i++)  fa[i] = i;
    for (int i = 2; i <= b; i++) {
        if(!fprime[i]){
            for(int j=i+i;j<=b;j+=i){
                fprime[j] = true;
                if(i>=p){
                    fa[find(j)] = i;
                }
            }
        }
    }
    int ans = 0;
    unordered_set<int> mp;
    for (int i = a; i <= b; i++){
        find(i);
        if(!mp.count(fa[i])){
            ans++;
            mp.insert(fa[i]);
        }
    }
    printf("%d\n", ans);
    return 0;
}
